Returns an array of group names that the user is immediately a member of.
#Include <AD.au3>
_AD_GetUserGroups([$sUser = @UserName[, $bIncludePrimaryGroup = False]])
Parameters
| $sUser | Optional: User for which the group membership is to be returned (default = @Username). Can be specified as Fully Qualified Domain Name (FQDN) or sAMAccountName |
| $bIncludePrimaryGroup | Optional: include the primary group to the returned list (default = False) |
Return Value
Success: Returns an one-based one dimensional array of group names (FQDN) the user is a member of
Remarks
Works for computers or groups as well.
Related
_AD_IsMemberOf, _AD_GetUserPrimaryGroup, _AD_RecursiveGetMemberOf
Example
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
; *****************************************************************************
; Example 1
; Get a sorted array of group names (FQDN) that the user is immediately a
; member of.
; *****************************************************************************
#include <AD.au3>
; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
; Get a sorted array of group names (FQDN) that the user is immediately a member of
Global $aUser = _AD_GetUserGroups(@ComputerName & "$") ;@UserName)
If @error > 0 Then
MsgBox(64, "Active Directory Functions - Example 1", "User '" & @UserName & "' has not been assigned to any group")
Else
_ArraySort($aUser, 0, 1)
_ArrayDisplay($aUser, "Active Directory Functions - Example 1 - Group names user '" & @UserName & "' is immediately a member of")
EndIf
; Close Connection to the Active Directory
_AD_Close()